
package com.horizon.mobile.view;

import zuo.biao.library.base.BaseModel;
import zuo.biao.library.base.BaseView;
import zuo.biao.library.ui.WebViewActivity;
import zuo.biao.library.util.Log;
import zuo.biao.library.util.StringUtil;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.horizon.mobile.R;
import com.horizon.mobile.activity.FlowDetailActivity;
import com.horizon.mobile.model.Todo;
import com.horizon.mobile.model.User;

/**
 * 待办View
 * 
 * @author 左大明
 */
public class TodoView extends BaseView<Todo> implements OnClickListener {
	private static final String TAG = "UserView";

	public TodoView(Activity context, Resources resources) {
		super(context, resources);
	}

	public TextView tvFlowName;

	public TextView tvTitle;
	public TextView tvTime;

	@SuppressLint("InflateParams")
	@Override
	public View createView(LayoutInflater inflater) {
		convertView = inflater.inflate(R.layout.todo_view, null);
		tvFlowName = findViewById(R.id.tvFlowname, this);
		tvTitle = findViewById(R.id.tvTitle, this);
		tvTime = findViewById(R.id.tvTime, this);
		return convertView;
	}

	@Override
	public void bindView(Todo data){
		if (data == null) {
			Log.e(TAG, "bindView data == null >> data = new User(); ");
			data = new Todo();
		}
		this.data = data;
		tvFlowName.setText(StringUtil.getTrimedString(data.getFlowName()));
		tvTitle.setText( StringUtil.getNoBlankString(data.getTitle()));
		if(data.getSendTime()!=null&& data.getSendTime().length()>0) {
			tvTime.setText(data.getSendTime());
		}else if(data.getStartTime()!=null){
			tvTime.setText(data.getStartTime());
		}
	}

	@Override
	public void onClick(View v) {
		if(data.getWorkId().length()==0){
			toActivity(FlowDetailActivity.createIntent(context,
					data.getId(), data
							.getTitle(),data.getTrackId(),data.getSubjectionId()));
		}else{
			toActivity(FlowDetailActivity.createIntent(context,
					data.getWorkId(), data
							.getTitle(),data.getTrackId(),data.getSubjectionId()));
		}
//		switch (v.getId()) {
//		
//		}
	}
}